home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
filecopy
/
modfilec.bas
< prev
Wrap
BASIC Source File
|
1998-07-31
|
2KB
|
56 lines
Attribute VB_Name = "modFileCopy"
Option Explicit
'--------------------------------------------------
'The following code was extracted from Microsoft
'technical support Article ID: Q172711
'
'WARNING:The following functions enable you to copy
'an open file. If the source file is changed while
'the copy operation is in process, the destination
'file may be incomplete or may become corrupted.
'--------------------------------------------------
Declare Function apiCopyFile Lib "kernel32" Alias "CopyFileA" _
(ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal bFailIfExists As Long) As Long
Sub WinFileCopy(SourceFile As String, DestFile As String)
'---------------------------------------------------------------
' PURPOSE: Copy a file on disk from one location to another.
' ACCEPTS: The name of the source file and destination file.
' RETURNS: Nothing
'---------------------------------------------------------------
'WinFileCopy "<path to Northwind.mdb>", "C:\Northwind.mdb"
Dim Result As Long
If Dir(SourceFile) = "" Then
MsgBox Chr(34) & SourceFile & Chr(34) & _
" is not valid file name."
Else
Result = apiCopyFile(SourceFile, DestFile, False)
End If
End Sub
Sub DosFileCopy(SourceFile As String, DestFile As String)
'---------------------------------------------------------------
' PURPOSE: Copy a file on disk from one location to another.
' ACCEPTS: The name of the source file and destination file.
' RETURNS: Nothing
'---------------------------------------------------------------
'DosFileCopy "<path to Northwind.mdb>", "C:\Northwind.mdb"
Dim CopyString As String
If Dir(SourceFile) = "" Then
MsgBox Chr(34) & SourceFile & Chr(34) & _
" is not a valid file name."
Else
SourceFile = Chr(34) & SourceFile & Chr(34)
DestFile = Chr(34) & DestFile & Chr(34)
CopyString = "COMMAND.COM /C COPY " & SourceFile & _
" " & DestFile
Call Shell(CopyString, 0)
End If
End Sub